package com.ld.campus_help.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ld.campus_help.entity.User;
import com.ld.campus_help.mapper.UserMapper;
import com.ld.campus_help.service.IUserService;
import com.ld.campus_help.util.Result;
import com.ld.campus_help.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;
    @Autowired
    private UserMapper userMapper;

    @PostMapping("/login")
    public Result signIn(@RequestBody User user){
        User result = userService.login(user.getStudentId(),user.getPassword(), user.getSchoolId());
        if(result != null){
            QueryWrapper<User> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("student_id", user.getStudentId());
            return ResultUtil.success(userMapper.selectOne(queryWrapper));
        }else{
            return ResultUtil.failure();
        }
    }

//        @PostMapping("/register")
//    public Result signUp(@RequestBody User user){
//
//
//
//    }


//    @PostMapping("/forget")
//    public void forget(){
//
//    }

}
